<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/component/commonTagLib.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
    <title>新增配送企业区域关系</title>
 <%@ include file="/WEB-INF/component/commonCSS.jsp" %>
    <!--[if lt IE 9]>
        <script src="lib/js/html5shiv.min.js"></script>
        <script src="lib/js/respond.min.js"></script>
    <![endif]-->
    <style type="text/css">
    span.required {
    		color: red;
    		margin-right: 6px;
    	}
    div.box-body {
    		margin-top:7px;
    	}	
    </style>
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1>新增配送企业区域关系</h1>
        <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i><spring:message code="message.lable.first"/></a></li>
            <li class="active"><a href="#">配送关系</a></li>
            <li class="active"><a href="#">配送企业区域管理</a></li>
        </ol>
    </section>
    <section class="content">
    <form role="form" class="form-horizontal" id="FormSubmit" action="stdCompinfoAdd.html" method="post">
              <div class=" box box-success">
                 <div class="box-header with-border">
                 <h3 class="box-title">配送企业区域信息</h3>
                 </div>      
                  <div class="box-body"> 
                    <div class="form-group form-group-xs">
                       
                        <label class="col-sm-2 text-right">配送企业：</label>
                        <div class="col-sm-10 text-left">
                        <input type="hidden" name ="compCode" id="compCode" value="" />
                        <span id="compName"></span>
                        <label onclick="$.HN.dialog.opendialog('delId','选择配送企业','${ctx}/baseDelAreaRel/toSelectComp.html?delId=delId&delTxt=delTxt','800px','400px',operResult)" class="btn btn-primary btn-sm">选  择</label>
                        </div>
                    </div> 
                    <div class="form-group form-group-xs">
                        
                        <label class="col-sm-2 text-right">区域：</label>
                        <div class="col-sm-10 text-left">
                        <input type="hidden" name="areaCode" id="areaCode" />
                        <span id="areaName"></span>
                        <label onclick="selectArea();" class="btn btn-primary btn-sm">选  择</label>
                        </div>
                    </div>
                    
                   </div> 
                   <div class="box-footer text-center">
                    <button type="button" onclick="save();" class="btn btn-success btn-sm"><spring:message code="message.button.saveSpacing"/></button>
                    <button type="button" onclick="window.location.href='${ctx}/baseDelAreaRel/toBaseDelAreaRelListCenter.html'" class="btn btn-danger btn-sm"><spring:message code="message.button.getBackSpacing"/></button>
                </div>  
            </div>
         </form> 
    </section>
    <%@ include file="/WEB-INF/component/commonJS.jsp" %>
    <script type="text/javascript">
    function save(){
    	if ($.trim($("#compCode").val()).length < 1){
    		top.$.HN.message.alert("请选择配送企业！", "<spring:message code="message.HN.alert.type"/>", "warn");
    		return;
    	}
    	if ($.trim($("#areaCode").val()).length < 1){
    		top.$.HN.message.alert("请选择配送区县！", "<spring:message code="message.HN.alert.type"/>", "warn");
    		return;
    	}
    	
    	$.post("${ctx}/baseDelAreaRel/saveDelArea.html", {
    		"compCode":$.trim($("#compCode").val()), "areaIds":$.trim($("#areaCode").val())
 		},
 		 		
 		function(result) {
 			if (result.success) {
 				top.$.HN.message.alert(result.msg, "<spring:message code="message.HN.alert.type"/>", "success");
 				window.location.href = "${ctx}/baseDelAreaRel/toBaseDelAreaRelListCenter.html";
 			} else {
 				top.$.HN.message.alert(result.msg, "<spring:message code="message.HN.alert.type"/>", "warn");
 				return;
 			}
 			
 		}, "json");
    	
    	
    	
    	
    }
    function selectArea(){
    	if ($.trim($("#compCode").val()).length < 1){
    		top.$.HN.message.alert("请选择配送企业！", "<spring:message code="message.HN.alert.type"/>", "error");
    		return;
    	}
    	$.HN.dialog.opendialog('delId','选择区域','${ctx}/baseDelAreaRel/toSelectArea.html?compCode='+$.trim($("#compCode").val())+'&delId=delId&delTxt=delTxt','800px','400px',operResultArea);
    }
    function operResult(val){
    	var strs = new Array();
        strs = val.split("|$");
        	if (val.length>0) {
        		$("#compCode").val(strs[2]);
        		  $("#compName").html(strs[3] );
			}	
    }
  function operResultArea(val){
	  var strs = new Array();
      strs = val.split("|$");
      	if (val.length>0) {
      		$("#areaCode").val(strs[2]);
      		  $("#areaName").html(strs[3] );
			}
  }
   
	
 	
 	

    </script>
</body>
</html>
